<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>强切账号管理</title>
<link rel="stylesheet" type="text/css" href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/icon.css">

<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<%
	/* String serverid = request.getParameter("serverid");
	String orgId = request.getParameter("orgId");
	String f_iocs_igsId = request.getParameter("f_iocs_igsId"); */
	
	String selectionsObj = request.getParameter("selectionsObj");	
	String []nonceObj=ConstantUtils.getNonceObject();
%>
<style type="text/css">
	table.tool_bar td {
		padding: 2px;
	}
</style>
</head>
<body>
	<%-- <input type="hidden" id="sessionId" value="${pageContext.session.id}" /> --%>
	<table id="easyui-datagrid"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar">
		<div class="easyuiSearch">
			<form id="tool_bar_form">
				<table class="tool_bar" width="90%">
					<tr>
						<td align="left">客户名称：</td>
						<td align="left"><input type="text" name="orgName" style="width: 150px;"/></td>
					</tr>
					<tr>
						<td align="left">
							地区：
						</td>
						<td align="left" colspan="3">
							<select id="prov" name="area_province" onchange="showCity(this);" style="width: 100px;">
								<option value="11">浙江省</option>
							</select>
							<select id="city" name="area_city" onchange="showCountry(this);" style="width: 100px;">
								<option value="">--请选择--</option>
							</select>
							<select id="country" name="area_county" style="width: 100px;">
								<option value="">--请选择--</option>
							</select>
						</td>
						<td align="left">
							<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search', plain:true" onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
						</td>
					</tr>
				</table>
				
			</form>
		</div>
	</div>
	<script type="text/javascript">
		/* "use strict"; */
		var queryParams;
		var $tool_bar_form = $("#tool_bar_form");
		var $datagrid = $("#easyui-datagrid");
		
		<%-- var serverid = '<%=serverid%>',
			orgId = '<%=orgId%>',
			f_iocs_igsId = '<%=f_iocs_igsId%>'; --%>
		
		var selectionsObj = '<%=selectionsObj%>';
		//将json数据解码并且将json格式转为数组格式
		var selections = JSON.parse( decodeURIComponent(selectionsObj) );
		
		function EasyuiDatagrid() {
			$datagrid.datagrid({
				url: '../../industry/behavior/group_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'f_igs_name',title:'分组名称',align:'center',width:205},
					{field:'f_igs_orgName',title:'行业客户',align:'center',width:260},
					{field:'f_igs_id',title:'操作',align:'center',width:70,
						formatter:function(value,row,index){
							var str ="";
							if(selections.length==1){
								
								if(selections[0].f_iocs_igsId == row.f_igs_id) {
									str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="alert(\'请勿重复绑定.\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">已绑定</span></span></a>';
								} else {
									str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="chooseGroup(\''+row.f_igs_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">绑定</span></span></a>';
								}
								
							}else{
								str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="chooseGroups(\''+row.f_igs_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">绑定</span></span></a>';
							}
							/* if(f_iocs_igsId == row.f_igs_id) {
								str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="alert(\'请勿重复绑定.\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">已绑定</span></span></a>';
							} else {
								str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="chooseGroup(\''+row.f_igs_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">绑定</span></span></a>';
							} */
							
							//str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="chooseGroups(\''+row.f_igs_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">绑定</span></span></a>';
							
							return str;
						}
					}
				]],
				singleSelect:true,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar'
			});
		}
	
		function getGueryParams(){
			return {
				orgName : $tool_bar_form.find("input[name='orgName']").val(),
				area_province : $tool_bar_form.find("select[name='area_province']").val(),
				area_city : $tool_bar_form.find("select[name='area_city']").val(),
				area_county : $tool_bar_form.find("select[name='area_county']").val()
			};
		}
		
		new EasyuiDatagrid();
		var gotoSearch = function(){
			$datagrid.datagrid('reload',getGueryParams());
		};
		
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
				if (event.keyCode == 13){
				gotoSearch($datagrid);
			}
		}
		
		//原绑定方法
		function chooseGroup(f_igs_id) {
			$.ajax({
				url: '../../industry/behavior/bind_org_serverid_group.do',
				data: {
					f_iocs_orgId : selections[0].f_iocs_orgId,
					f_iocs_serverid : selections[0].f_iocs_serverid,
					f_iocs_igsId : selections[0].f_iocs_igsId,
					fIocsIgsId : f_igs_id,
					stime : "<%=nonceObj[0]%>",
					sign : "<%=nonceObj[1]%>"
				},
				dataType: "json",
				type: "GET",
				success: function(data) {
					if(data.flag > 0) {
						parent.$('#dlg').dialog('close');
						parent.gotoSearch();
						$.ajax({
							url: "../../cache/clear_web_cache.do",
							type: "GET",
							data: {},
							dataType: "json",
							success: function(data) {}
						});
					} else {
						alert("绑定失败!");
					}
					window.location.reload();
				}
			});
		}
		
		//现在批量绑定方法
		function chooseGroups(f_igs_id) {
			
			$.ajax({
				url: '../../industry/behavior/bind_org_serverid_groups.do',
				data: {
					industryGroupSchedulesVoString : selectionsObj,
					fIocsIgsId : f_igs_id,
					deleteOrBindType : 0,
					stime : "<%=nonceObj[0]%>",
					sign : "<%=nonceObj[1]%>"
				},
				dataType: "json",
				type: "GET",
				success: function(data) {
					if(data.flag > 0) {
						parent.$('#dlg').dialog('close');
						parent.gotoSearch();
						$.ajax({
							url: "../../cache/clear_web_cache.do",
							type: "GET",
							data: {},
							dataType: "json",
							success: function(data) {}
						});
					} else {
						alert("绑定失败!");
					}
					window.location.reload();
				}
			});
		}
		
	</script>
	<script type="text/javascript" src="../../static/js/city/city.js"></script>
	<script type="text/javascript" src="../../static/js/city/method01.js"></script>
</body>
</html>